package com.lbs.tdrive.comon;

import java.util.ArrayList;
import java.util.EventListener;

import android.os.AsyncTask;

public class HttpASync extends AsyncTask<String, Void, Void> {

	private ArrayList<OnRequest> listeners;
	
	public interface OnRequest{
		public void onResponseReceived(String response);
	}
	
	@Override
	protected Void doInBackground(String... arg0) {
		String url = arg0[0];
		System.out.println("url = "+url);
		String respStr=HttpRequest.getResponse(url);
		OnRequest obj = listeners.get(0);
		obj.onResponseReceived(respStr);
		return null;
	}
	
	
	public void setOnRequestListener(OnRequest listener) {
		if(listeners!=null){
			listeners= null;
		}
		listeners = new ArrayList<OnRequest>();
		
		listeners.add(listener);

	}


}
